# encoding: UTF-8

class Admin::FeaturesController < ApplicationController

  before_filter :user_signed_in?
  
  def index
    @features = Feature.all
    set_seo_meta '游戏特色'
  end

  def new
    set_seo_meta '游戏特色添加'
  end

  def create
    @feature = Feature.new(params[:session])
    if @feature.save
      redirect_to features_path, notice: '新增成功'
    else
      redirect_referrer_or_default
    end  
  end

  def edit
    @feature = Feature.find(params[:id])
    set_seo_meta '游戏特色修改'
  end

  def update
    @feature = Feature.find(params[:id])
    if @feature.update_attributes(params[:session])
      redirect_to features_path, notice: '修改成功'
    else
      redirect_referrer_or_defautl default
    end
  end

  def destroy
    if Feature.delete(params[:id])
      redirect_to features_path, notice: '删除成功'
    else
      redirect_referrer_or_default default
    end  
  end

end
